package com.woniu.service.productcommand;

import com.woniu.inlet.fo.ProductFo;
import com.woniu.outlet.mysql.po.Product;
import com.woniu.util.ApplicationContextHolder;
import lombok.Data;

import java.util.List;

/**
 * @description:
 * @author: my
 * @time: 2021/4/26 19:36
 */
@Data
public class QueryProductsCommand {
    private QueryProductCommandHandler handler;
    private ProductFo productFo;

    public QueryProductsCommand(){
        this.handler =
                ApplicationContextHolder.getApplicationContext().getBean(QueryProductCommandHandler.class);
    }

    public QueryProductsCommand(ProductFo productFo){
        this();
        this.productFo = productFo;
    }

    public List<Product> execute(){
        return this.handler.action(this);
    }
}
